<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<script type='text/javascript' src='../dwr/interface/PerformanceReportAction.js'></script>
<script type="text/javascript" src="../resource/js/hrm/perform.js"></script>
<script type="text/javascript">
function getTableHeadHtml(titleList){
	var thHtmlStr = ' <TR style="height:15px;">';
	for(var i=0;i<titleList.length;i++){
		if(i ==2){
			thHtmlStr += '  <TH noWrap width="45%" style="height: 20px;color: #666666;font-size: 12px;font-weight: bold;text-align: center;border-bottom: 1px solid #980000;padding-left:4px;padding-right:4px;background-color:#D0E8F4;">';
			thHtmlStr += titleList[i];
			thHtmlStr += '  </TH>';
		}else if(i >2){
			thHtmlStr += '  <TH noWrap width="45px" style="height: 20px;color: #666666;font-size: 12px;font-weight: bold;text-align: center;border-bottom: 1px solid #980000;padding-left:4px;padding-right:4px;background-color:#D0E8F4;">';
			thHtmlStr += titleList[i];
			thHtmlStr += '  </TH>';
		}else {
			thHtmlStr += '  <TH noWrap style="height: 20px;color: #666666;font-size: 12px;font-weight: bold;text-align: center;border-bottom: 1px solid #980000;padding-left:4px;padding-right:4px;background-color:#D0E8F4;">';
			thHtmlStr += titleList[i];
			thHtmlStr += '  </TH>';
		}
	}
	thHtmlStr += '</TR>';
	return thHtmlStr;
}

// 处理报表表格的函数
function getReportTableHtml(planScoreList,perfplan){
	var tempTrsHtml = '';
	for(var i=0;i<planScoreList.length;i++){
		if(planScoreList[i].myRowSpan != null) {
			tempTrsHtml += '<TR  style="height:15px;">'
			+'	<TD  style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;" align="center" rowspan="'+planScoreList[i].myRowSpan+'">'+planScoreList[i].ppsPcId.pcPctId.pctName+'</br>(权重'+planScoreList[i].myPercent+'%)</TD>';
		} else {
			tempTrsHtml += '<TR  style="height:15px;">';
		}
			tempTrsHtml +=	 '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;" ><label >'+planScoreList[i].ppsPcId.pcName+'</label><label>('+planScoreList[i].ppsPercentage+'%)</label></TD>';
			tempTrsHtml +=   '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;" ><label >'+planScoreList[i].ppsPcId.pcDesc+'</label></TD>';
			
			tempTrsHtml +=   '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;"  ><label >'+planScoreList[i].degreeA+'</label></TD>';
			tempTrsHtml +=   '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;"><label >'+planScoreList[i].degreeB+'</label></TD>';
			tempTrsHtml +=   '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;" ><label >'+planScoreList[i].degreeC+'</label></TD>';
			tempTrsHtml +=   '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;"><label >'+planScoreList[i].degreeD+'</label></TD>';
			tempTrsHtml +=   '	<TD style="border: 1px #ADD7FC solid;border-top-width: 0px;border-left-width: 0px;word-wrap:break-word;overflow:hidden;padding-left:4px;padding-right:4px;padding-top:4px;padding-bottom:4px;font-size:12px;"><label >'+planScoreList[i].degreeE+'</label></TD>';
		tempTrsHtml += ' </TR>';
	}
	if(planScoreList.length == 0)tempTrsHtml += '<TR style="height:15px;"><td clospan="8" ><h1>没有考核指标！</h1></td></TR>';
	return tempTrsHtml;
}

//初始化
function initTableList() {

	// 检查考核周期
	if(!checkPeriod('select05'))return ;
	
	// 检查考核方案
	if(!checkSchema('select05')) return ;
	
	// 检查区间
	if(!checkZone('select05')) return;
	
	var temp_period = $('#select05_pppId').val();
	
	var temp_schema = $('#select05_psId').val();
	
	var degreeStr = a_height+"_"+a_low+";"+
					b_height+"_"+b_low+";"+
					c_height+"_"+c_low+";"+
					d_height+"_"+d_low+";"+
					e_height+"_"+e_low;
	var tempDeptid = $('#orgselector_returnString_orgselector_select05').val()

	clearShow();					
	$('#divWait').show();
	PerformanceReportAction.showReportTable(temp_period,temp_schema,degreeStr,tempDeptid,showReportPerf);
}

function showReportPerf(perfplan){
	$('#divWait').hide();
	if(perfplan == null || !perfplan){
		alert("没有数据！");
		return;
	}
	
	// 指标占得行数
	var critRows = 0;
	// 得到内容格式
	var tableHtmlFunction;
	var tempHtml;
	// 得到标题
	var tableHtml= getTableHeadHtml(perfplan.titleList);
	var planScoreList = perfplan.planScoreList;
	var regS = new RegExp("null","gi");
	
	// 设置一下td的rowspan
	hrm.perform.checkRowSpan(planScoreList);
	// 设置一下显示百分比的
	hrm.perform.showPercent(planScoreList);
	tableHtmlFunction=eval("getReportTableHtml");
	tempHtml = tableHtmlFunction(planScoreList,perfplan);
 	tableHtml += tempHtml.replace(regS,'');
 	tableHtml ='<table width="100%" cellSpacing="0" cellPadding="0" class="gridview" style="border: 1px #6BB5DA solid;empty-cells: show;border-collapse: separate !important;border-collapse: collapse;border-spacing: 0px;" >'+tableHtml+'</table>';
	$("#reportArea").contents().find('body').html(tableHtml)
}
			
</script>